$productDetailList=$("#productDetailTable");
$(function () {
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return (r[2]); return null;
    }
    var sname=GetQueryString('companyId')
    var startTime=GetQueryString('startTime')
    var endTime=GetQueryString('endTime')
    var typeTime=GetQueryString('typeTime')


    // params.arriveTimeStart=$("#arriveTimeStart").val()
    // params.arriveTimeEnd=$("#arriveTimeEnd").val()
    // params.dateType=$("#dateType").val()

    console.log(sname,startTime,endTime,typeTime)

    $("#companyId").val(sname)
    $("#arriveTimeStart").val(startTime)
    $("#arriveTimeEnd").val(endTime)
    $("#dateType").val(typeTime)
    productDetailFun()

})
function orderStatusHtml(value, row, index) {
    let html = '';
    //onclick="detailSee()"
    if(row.orderStatus==1){
        html='等待回款'
    }else if(row.orderStatus==2){
        html='已完成'
    }else if(row.orderStatus==3){
        html='作废'
    }else if(row.orderStatus==4){
        html='部分回款'
    }else{
        html='-'
    }

    return html
}

function indexFormat(value, row, index) {
    return index + 1;
}

function toOrderInfo(value, row, index) {
    if(value == null) {
        return '<span href="JavaScript:void(0);">-</span>';
    }else {
        //onclick=\'OrderDetail(\"'+row.orderNumber+'")\'
        return '<a href="JavaScript:void(0);" onclick=\'OrderDetail(\"'+row.orderId+'")\'>'+value+'</a>';
    }
}

function OrderDetail(orderNumber) {
    parent.$(parent.document).data('multitabs').create({
        iframe: true,
        title: '订单详情',
        url: "/front/finance/orderInfoByNumber?productOrderNumber="+orderNumber
    },true);
}
function productDetailFun(){
    $productDetailList.bootstrapTable('destroy');
    $productDetailList.bootstrapTable({
        //table table-bordered table-hover table-striped
        classes: 'table table-hover table-bordered table-striped',
        url: '/returnMoney/selectReturnMoneyList',//请求地址
        method: 'post',//请求方式
        contentType: "application/x-www-form-urlencoded",//请求内容类型
        dataType: "json",//数据类型
        striped: false,//是否显示行间隔色
        sortable: false,//是否启用排序
        sortOrder: "desc",//排序方式
        sortName: 'createTm',//排序字段
        cache: false,//是否使用缓存
        showColumns: false,//显示隐藏列
        showRefresh: false,//显示刷新按钮
        showToggle: false,//切换显示样式
        showFooter: false,//显示Table脚部
        pagination: true,//是否显示分页
        showPaginationSwitch: false,//是否显示分页按钮
        clickToSelect: false,//是否启用点击选中行
        singleSelect: false,
        minimumCountColumns: 2,//最少要显示的列数
        undefinedText: '-',//cell没有值时显示
        sidePagination: "server",//分页方式：client客户端分页，server服务端分页
        uniqueId: 'logId',
        idField: 'logId',
        pageSize: 10,//每页的记录行数
        pageNumber: 1,//初始化加载第1页，默认第1页
        pageList: "[10]",//可供选择的每页的行数

        fixedColumns: true,     // 冻结列
        fixedNumber: 1,         // 左侧固定列
        fixedRightNumber: 2,    // 右侧固定列

        queryParams: function (params) {
            params.pageSize = params.limit;
            params.pageIndex = (params.offset / params.limit) + 1;
            params.companyId=$("#companyId").val()
            params.arriveTimeStart=$("#arriveTimeStart").val()
            params.arriveTimeEnd=$("#arriveTimeEnd").val()
            params.dateType=$("#dateType").val()
            // params.bs=0;
            return params;
        },//查询参数
        columns: [
            {title: '主键', field: 'logId', visible: false},
            {title: '序号', field: 'index', align: 'center', valign: 'left', width: '60', formatter: indexFormat},
            {title: '订单编号', field: 'orderId', align: 'left', valign: 'middle', formatter: toOrderInfo},
            {title: '订单状态', field: 'orderStatus', align: 'left', valign: 'middle',formatter:orderStatusHtml},
            {title: '订单金额', field: 'orderActualTotalAmount', align: 'left', valign: 'middle'},
            {title: '到款金额', field: 'arriveMoney', align: 'left', valign: 'middle'},
            {title: '所有人', field: 'salesmanName', align: 'left', valign: 'middle'},
            {title: '到款时间', field: 'arriveTime', align: 'left', valign: 'middle'},
            {title: '录入时间', field: 'createTm', align: 'left', valign: 'middle'},
            {title: '录入人', field: 'createByName', align: 'left', valign: 'middle'},
        ],
        responseHandler: function (result) {
            if (result.code == "000000") {
                var obj = {
                    "rows": result.data,
                    "total": result.totalRecords//总条数
                };
            } else {
                var obj = {
                    "total": 0,
                    "rows": [],
                }
            }
            return obj;
        },
        onLoadSuccess: function () {

        },
        onLoadError: function (status) {
            if (status == 403) {
                alert("权限不足！禁止访问！");
            } else {
                //加载失败时执行
                alert("加载失败！");
            }
        },
        formatLoadingMessage: function () {
            return "请稍等，加载中...";
        },
        formatNoMatches: function () {
            return '无符合条件的记录';
        },
    });
}